/**
 * 安全设置对象的值
 * @param {*} originData 原始数据
 * @param {*} path 路径
 * @param {*} value 值
   要求是safeSetValueByPath({key1:'value1'},'key1','newvalue')
   结果是{key1:'newvalue'}
   要求是safeSetValueByPath({key1:'value1'},'key2.subKey2.subKey3','subValue3')
   结果是{key1:value1,key2:{subKey2:{subKey3:'subValue3'}}}
   要求是safeSetValueByPath({key1:0},'key1.subKey1','subValue1')
   结果是{key1:0}
   要求是safeSetValueByPath({key1:null},'key1.subKey1','subValue1')
   结果是{key1:null}
   要求是safeSetValueByPath({key1:undefined},'key1.subKey1','subValue1')
   结果是{key1:undefined}
 */
function safeSetValueByPath(originData,path,value){
  const keys = path.split('.')
  const lastKey = keys.pop()
  const lastObject = keys.reduce((obj,key)=>obj[key],originData)
  lastObject[lastKey] = value
  return originData 
}